// import $t from '@/z/function/$t.js'
const $t = str => str
const state = {
	USearch: {},
	titmc: "",
	language: uni.getStorageSync('language') || "English"
};
const getters = {
	langg() {
		// return "en"
		// #ifndef APP-PLUS 
		return "zh"
		// #endif
		return state.language === '中文' ? "zh" : "en"
	}
};
const mutations = {
	setUSearch(state, USearch) {
		state.USearch = USearch;
	},
	settitmc(state, titmc) {
		state.titmc = titmc;
	},
	setLanguage(state, payload) {
		console.log('设置语言')
		state.language = payload;
	},
};
const actions = {
	async GetAppinfofn({
		state,
		commit
	}) {
		if (state.titmc == "") {
			let GetAppinfo = await uni.$z.request("/GetAppinfo");
			let titmc = GetAppinfo.length == 1 ? GetAppinfo[0].AppName : "";
			commit("settitmc", titmc);
			return titmc;
		} else {
			return state.titmc;
		}
	},
	async getuser({
		commit,
		state
	}, qzsx = false) {
		let GetSession = await uni.$z.request("/GetSession");
		uni.setStorageSync('utype', GetSession[0].utype || '')
		if (GetSession[0].utype == "99") {
			// uni.showModal({
			// 	content: $t("请退出重新登录"),
			// 	showCancel: false,
			// });
			return Promise.reject($t("登录状态失效错误"));
		}
		let uUser = GetSession[0].uUser;
		if (uUser != state.USearch.uUser || qzsx) {
			let USearch = await uni.$z.request("/USearchSys", {
				uUser: uUser,
			});
			commit("setUSearch", USearch[0]);
		}
		return state.USearch;
	},
};
export default {
	state,
	getters,
	mutations,
	actions,
};